@extends('backend::layout')

@section('title', '干预训练内容列表')

@section('content')
    <div class="card border-no">
        <div class="card-body">
            @if(!empty($currentAdmin) && $currentAdmin->allow('game/add') && !empty($currentAdmin) && $currentAdmin->allow('game/import'))
            <div class="row">
                <div class="clearfix"></div>
                <div class="col-md-12 col-sm-12 col-xs-12 pull-right">
                    <p>
                        @if(!empty($currentAdmin) && $currentAdmin->allow('game/add'))
                            <a href="{{ route('admin.game.add') }}" class="btn btn-primary btn-sm">新增干预训练内容</a>
                        @endif

                        @if(!empty($currentAdmin) && $currentAdmin->allow('game/import'))
                            <a href="{{ route('admin.game.import') }}" class="btn btn-danger btn-sm">导入干预训练内容</a>
                        @endif
                    </p>
                </div>
            </div>
            @endif
            <form method="get">
                <div class="row">
                    <div class="clearfix"></div>
                    <div class="col-md-12 col-sm-12 col-xs-12">
                        <label class="col-md-2 col-sm-12">
                            <input class="form-control" type="text" placeholder="编号" name="code" value="{{ old("code") ?: (isset($query['code']) ? $query['code'] : '') }}" />
                        </label>
                        <label class="col-md-2 col-sm-12">
                            <input class="form-control" type="text" placeholder="项目名称" name="name" value="{{ old("name") ?: (isset($query['name']) ? $query['name'] : '') }}" />
                        </label>

                        <label class="col-md-2 col-sm-12">
                            <select class="form-control" name="grade_id">
                                <option  value="">--{{__("grade")}}--</option>
                                @foreach($grades as $val)
                                    <option value="{{ $val->id }}" @if(old('grade_id') === $val->id || (old('grade_id') === null && (isset($query['grade_id']) && $query['grade_id'] ==  $val->id )) ) selected @endif >{{ $val->name }}</option>
                                @endforeach
                            </select>
                        </label>

                        <label class="col-md-2 col-sm-12">
                            <select class="form-control" name="category_id">
                                <option  value="">--{{__("category")}}--</option>
                                @foreach($categories as $val)
                                    <option value="{{ $val->id }}" @if(old('category_id') === $val->id || (old('category_id') === null && (isset($query['category_id']) && $query['category_id'] ==  $val->id )) ) selected @endif >{{ $val->name }}</option>
                                @endforeach
                            </select>
                        </label>


                        <label class="col-md-2 col-sm-12">
                            <button class="btn btn-primary btn-sm">搜索</button>
                        </label>
                    </div>
                </div>
            </form>

            <h4 class="text-black f-20">干预训练内容列表</h4>
            <div class="table-responsive">
                <table class="table table-hover">
                    <thead>
                    <tr>
                        <th scope="col">#</th>
                        <th scope="col">{{ __("code") }}</th>
                        <th scope="col">{{ __("Name") }}</th>
                        <th scope="col">{{ __("grade") }}</th>
                        <th scope="col">{{ __("category") }}</th>
                        <th scope="col">{{ __('Options') }}</th>
                    </tr>
                    </thead>
                    <tbody>
                    @if(isset($list))
                        @foreach($list as $idx => $item)
                            <tr>
                                <th scope="row">{{ $idx + 1 }}</th>
                                <td>{{ $item->code }}</td>
                                <td>{{ $item->name }}</td>
                                <td>{{ $item->grade->name }}</td>
                                <td>{{ $item->category->name }}</td>
                                <td>
                                    @if($currentAdmin->allow('game/edit'))
                                        <a href="{{ route('admin.game.edit', ['id' => $item->id]) }}" class="text-info"
                                           title="{{ __('Edit') }}">&nbsp;&nbsp;<i class="fa fa-pencil"></i></a>
                                    @endif

                                    @if($currentAdmin->allow('game/delete'))
                                        <a href="{{ route('admin.game.delete', ['id' => $item->id]) }}"
                                           class="text-danger confirm-delete" title="{{ __('Delete') }}">&nbsp;&nbsp;<i
                                                    class="fa fa-trash-o"></i></a>
                                    @endif
                                </td>
                            </tr>
                        @endforeach
                    @endif
                    </tbody>
                </table>
            </div>
            <div class="row">
                <div class="clearfix"></div>
                <div class="col-md-12 col-sm-12 col-xs-12 pull-right">
                    @if(isset($list))
                        {{ $list->links() }}
                    @endif
                </div>
            </div>
        </div>
    </div>
@stop